<?php
session_start();
$total = 0;
include 'header.php';?>
<div class="body">
    <div class="article">
        <div class="header">
            <h3>Hóa đơn</h3>
        </div>
        <div class="extra-wrap" style="padding-left: 332px !important;">
            <style>
                table, th, td {
                    border: 1px solid black;
                    border-collapse: collapse;
                    padding: 5px;
                }
            </style>
            <table>
                <tbody>
                <tr>
                    <td>Họ và tên:</td>
                    <td><?php echo $_POST['name'] ?></td>
                </tr>
                <tr>
                    <td>Điện thoại:</td>
                    <td><?php echo $_POST['tel'] ?></td>
                </tr>
                <tr>
                    <td>Địa chỉ:</td>
                    <td><?php echo $_POST['address'] ?></td>
                </tr>

                <tr>
                    <td colspan="2"><b>Hàng hóa:</b></td>
                </tr>

                <?php
                if (!empty($_SESSION['cart'])) {
                    foreach ($_SESSION['cart'] as $k => $v) {
                        ?>
                        <tr>
                            <td>Mã số:</td>
                            <td><?php echo $k; ?></td>
                        </tr>
                        <tr>
                            <td>Sản phẩm:</td>
                            <td><?php echo $v['name']; ?></td>
                        </tr>
                        <tr>
                            <td>Giá:</td>
                            <td><?php echo $v['price']; ?> VND</td>
                        </tr>
                        <tr>
                            <td>Số lượng:</td>
                            <td><?php echo $v['qty']; ?></td>
                        </tr>

                        <?php $total += ($v['price'] * $v['qty']);
                        ?>
                    <?php
                    }
                }
                ?>
                <tr>
                    <td><b>Tổng tiền:</b></td>
                    <td><b><?php echo $total;
                            session_destroy(); ?> VND</b></td>
                </tr>

                </tbody>
            </table>
        </div>
    </div>
<?php
include 'footer.php';?>